home *** CD-ROM | disk | FTP | other *** search
- From: Nico Josuttis <nico@bredex.de>
- Message-ID: <199604020924.LAA07380@bredex.bredex.de>
- X-Original-Date: Tue, 02 Apr 96 11:24:07 +0200
- Path: in2.uu.net!bounce-back
- Date: 02 Apr 96 13:32:05 GMT
- Approved: fjh@cs.mu.oz.au
- Organization: -
- Newsgroups: comp.std.c++
- X-Authentication-Warning: bredex.bredex.de: Host localhost didn't use HELO protocol
- Cc: nico@bredex.de
- Subject: reserve() and capacity()
- X-Mts: smtp
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMWEsdeEDnX0m9pzZAQG1ugGAkaFnOiPzXUutcWPoxx1i9X33KRm7a2SE
- 0TPrBgS8dYx23KDBq5iF7V+AWHNx76b6
- =FQZn
-
- Two "container" have reserve() and capacity():
- string and vector.
- For both first a simple hint:
- The january draft says, that
- It is guaranteed that no
- reallocation takes place during the insertions that happen after
- reserve() takes place till the time when the size of the vector/string
-
- reaches the size specified by reserve().
- First "reaching" the size should also guarantee that no reallocation takes
- place. I think "exceeds" would be the correct naming here.
-
- But I have deeper questions:
- For vectors for every member function it is documented how it unvalidates
- iterators and references.
- Following that I would guess that
- a) vector capacity in general can't shrink
- b) iterators stay valid even if following elements get destroyed
- On the other hand the standard says that
- a) no reallocation takes place during the INSERTIONS ...
- b) The reference returned by the non-const version is invalid after any
- subsequent call to c_str(), data(), or any non-const member function
- for the object.
- (only for string, the vector version is missing)
-
- So my questions are:
- - What is right for vector and string?
- - How long stay iterators and references valid for both?
- - May the capacity() shrink for both?
-
- Thanks in advance
- --------
- Nico address: BREDEX GmbH
- email: nico@bredex.de Nicolai Josuttis
- Fallersleber-Tor-Wall 23
- phone: +49 531 24330-0 D-38100 Braunschweig
- fax: +49 531 24330-99 Germany
- --------
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-